use std::io;
use rand::Rng;
use std::cmp::Ordering;

fn guess_number() {
	let rand_num = rand::thread_rng().gen_range(1,101);
	// test use
	// println!("rand: {}", rand_num);

	loop{
		println!("enter a your guess:");
		let mut guess = String::new();
		io::stdin().read_line(&mut guess).expect("fail");
		println!("your guess: {}", guess);

		let guess: i32 = match guess.trim().parse() {
			Ok(number) => number,
			Err(_) => {
				println!("please ensure your input are number!!!");
				continue;
			},
		};
		match guess.cmp(&rand_num) {
			Ordering::Less => println!("less"),
			Ordering::Greater => println!("Greater"),
			Ordering::Equal => {
			println!("Equal");
				break;
			}
		}
	}
}
